package activity;

import com.qzhy.female.R;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class StartActivity extends ActionBarActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_start);
		ImageView imageView = (ImageView) findViewById(R.id.img_login);
		Animation animation = AnimationUtils.loadAnimation(this, R.anim.login_anim);
		imageView.setAnimation(animation);
		animation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {
			}
			@Override
			public void onAnimationRepeat(Animation animation) {
			}
			
			@Override
			public void onAnimationEnd(Animation animation) {
				SharedPreferences sp = getSharedPreferences("local", Context.MODE_PRIVATE);
				boolean hasLogin = sp.getBoolean("is_first", false);
				if(hasLogin)
				{
					startActivity(new Intent(StartActivity.this,MainActivity.class));
				
				}else
				{
					startActivity(new Intent(StartActivity.this,MainActivity.class));
//					startActivity(new Intent(StartActivity.this,GuideActivity.class));
					sp.edit().putBoolean("is_first", true).commit();
				}
				StartActivity.this.finish();
			}
		});
	}
}